From bd915073f92a39187f76facda58a9958337eace5 Mon Sep 17 00:00:00 2001 From: Victor Vasiliev Date: Sun, 28 Sep 2008 19:34:14 +0000 Subject: [PATCH] * Fix caching * Fix messages --- includes/User.php | 4 ++-- includes/specials/SpecialRemoveRestrictions.php | 2 ++ includes/specials/SpecialRestrictUser.php | 15 +++++++++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/includes/User.php b/includes/User.php index 2efe9f109e..c1ce092552 100644 --- a/includes/User.php +++ b/includes/User.php @@ -14,7 +14,7 @@ define( 'USER_TOKEN_LENGTH', 32 ); * \type{\int} Serialized record version. * @ingroup Constants */ -define( 'MW_USER_VERSION', 6 ); +define( 'MW_USER_VERSION', 7 ); /** * \type{\string} Some punctuation to prevent editing from broken text-mangling proxies. @@ -3245,7 +3245,7 @@ class User { // Restrictions-related block public function loadRestrictions() { - if( !$this->mRestrictions ) + if( is_null( $this->mRestrictions ) ) $this->mRestrictions = UserRestriction::fetchForUser( $this->isLoggedIn() ? intval( $this->getId() ) : $this->getName() ); } diff --git a/includes/specials/SpecialRemoveRestrictions.php b/includes/specials/SpecialRemoveRestrictions.php index ded6cbe3d7..5ad21ddb9b 100644 --- a/includes/specials/SpecialRemoveRestrictions.php +++ b/includes/specials/SpecialRemoveRestrictions.php @@ -56,5 +56,7 @@ function wfSpecialRemoveRestrictionsProcess( $r ) { if( $r->isNamespace() ) $params[] = $r->getNamespace(); $log->addEntry( 'remove', Title::makeTitle( NS_USER, $r->getSubjectText() ), $reason, $params ); + $userObj = User::newFromName( $r->getSubjectText(), false ); + $userObj->invalidateCache(); return $result; } diff --git a/includes/specials/SpecialRestrictUser.php b/includes/specials/SpecialRestrictUser.php index 86de2d1db7..edf5f221d0 100644 --- a/includes/specials/SpecialRestrictUser.php +++ b/includes/specials/SpecialRestrictUser.php @@ -106,7 +106,7 @@ class RestrictUserForm { if ( $error ) $wgOut->wrapWikiMsg( '$1', $error ); if ( $success ) - $wgOut->wrapWikiMsg( '$1/strong>', $success ); + $wgOut->wrapWikiMsg( '$1', $success ); } public static function doPageRestriction( $uid, $user ) { @@ -126,6 +126,7 @@ class RestrictUserForm { $l = new LogPage( 'restrict' ); $l->addEntry( 'restrict', Title::makeTitle( NS_USER, $user ), $r->getReason(), array( $r->getType(), $r->getPage()->getFullText(), $logExpiry) ); + self::invalidateCache( $user ); } public static function namespaceRestrictionForm( $uid, $user, $oldRestrictions ) { @@ -136,13 +137,13 @@ class RestrictUserForm { $wgUser->matchEditToken( $wgRequest->getVal( 'edittoken' ) ) ) { $ns = $wgRequest->getVal( 'namespace' ); if( $wgContLang->getNsText( $ns ) === false ) - $error = wfMsgExt( 'restrictuser-badnamespace', 'parseinline' ); + $error = array( 'restrictuser-badnamespace' ); elseif( UserRestriction::convertExpiry( $wgRequest->getVal( 'expiry' ) ) === false ) - $error = wfMsgExt( 'restrictuser-badexpiry', 'parseinline', $wgRequest->getVal( 'expiry' ) ); + $error = array( 'restrictuser-badexpiry', $wgRequest->getVal( 'expiry' ) ); else foreach( $oldRestrictions as $r ) if( $r->isNamespace() && $r->getNamespace() == $ns ) - $error = wfMsgExt( 'restrictuser-dupnamespace', 'parse' ); + $error = array( 'restrictuser-dupnamespace' ); if( !$error ) { self::doNamespaceRestriction( $uid, $user ); $success = array('restrictuser-success', $user); @@ -185,5 +186,11 @@ class RestrictUserForm { $l = new LogPage( 'restrict' ); $l->addEntry( 'restrict', Title::makeTitle( NS_USER, $user ), $r->getReason(), array( $r->getType(), $r->getNamespace(), $logExpiry ) ); + self::invalidateCache( $user ); + } + + private static function invalidateCache( $user ) { + $userObj = User::newFromName( $user, false ); + $userObj->invalidateCache(); } } -- 2.20.1